# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------
# $Id: admin.py 33 2010-02-24 01:57:24Z semente $
# ----------------------------------------------------------------------------
#
#  Copyright (c) 2008 Guilherme Mesquita Gondim
#
#  This file is part of django-fleshin.
#
#  django-fleshin is free software under terms of the GNU General
#  Public License version 3 (GPLv3) as published by the Free Software
#  Foundation. See the file README for copying conditions.
#

from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from fleshin.models import Album, Photo
from fleshin.settings import HAS_TAG_SUPPORT

if HAS_TAG_SUPPORT:
    TAG_FIELD = ['tags']
else:
    TAG_FIELD = []


class AlbumAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('name',)}

class PhotoAdmin(admin.ModelAdmin):
    date_hierarchy = 'pub_date'
    fieldsets = (
        (None, {
            'fields': ('photo', 'caption', 'slug', 'album')
        }),
        (_('Photo detail'), {
            'fields': ['date', 'time', 'place', 'description',
                       'photographer'] + TAG_FIELD
        }),
        (_('Status'), {
            'fields': ('is_published', 'publish_on')
        }),
        (_('Discussion'), {
            'fields': ('enable_comments',)
        }),
        (_('Advanced options'), {
            'classes': ('collapse',),
            'fields': ('pub_date',),
        })
    )
    list_display  = ('caption', 'pub_date', 'width', 'height', 'album',
                     'is_published', 'enable_comments')
    list_filter   = ('is_published', 'publish_on', 'enable_comments', 'album')
    search_fields = ('photo', 'slug', 'place', 'caption', 'description')
    prepopulated_fields = {'slug': ('caption',)}

admin.site.register(Album, AlbumAdmin)
admin.site.register(Photo, PhotoAdmin)
